package com.qianyucc.blog.controller.admin;

import com.qianyucc.blog.model.dto.*;
import com.qianyucc.blog.model.vo.*;
import com.qianyucc.blog.service.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.*;
import javax.xml.transform.*;

/**
 * @author lijing
 * @e-mail 1413979079@qq.com
 * @date 2020-04-20 18:21
 * @description 管理员用户
 */
@RestController("adminUserController")
@RequestMapping("/admin/user")
public class UserController {
    @Autowired
    private ConfigService configService;

    @RequestMapping("/token")
    public ResultVO token(String token) {
        boolean res = configService.checkToken(token);
        return res ? ResultVO.ok("已登录") : ResultVO.ok("token已经过期");
    }

    @PostMapping("/")
    public ResultVO login(@RequestBody AdminUserDTO user) {
        String token = configService.login(user);
        return token != null ? ResultVO.ok(token) : ResultVO.error("登录失败");
    }
}
